package leecode

import "sort"

func secondHighest(s string) (result int) {
	arr := []byte(s)
	hashMap := make(map[byte]int)
	for i := 0; i < len(arr); i++ {
		if arr[i] >= '0' && arr[i] <= '9' {
			hashMap[arr[i]]++
		}
	}
	temp := make([]int, 0, len(hashMap))
	for key, _ := range hashMap {
		temp = append(temp, int(key))
	}
	sort.Ints(temp)
	if len(temp) < 2 {
		return -1
	}
	return temp[len(temp)-2] - 48
}
